package com.atguigu.gmall.order.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.biz.OrderBizService;
import com.atguigu.gmall.order.vo.OrderSubmitVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * @author:ahang
 * @create:2022-10-24 12:08
 * @Description:
 */
@RestController
@RequestMapping("/api/order/auth")
public class OrderRestController {
    @Autowired
    OrderBizService orderBizService;

    @PostMapping("/submitOrder")
    public Result submitOrder(@Valid @RequestBody OrderSubmitVo orderSubmitVo,
                              @RequestParam("tradeNo") String tradeNo){

        //前端提交过来的订单数据保存数据库
        Long orderId = orderBizService.submitOrder(orderSubmitVo,tradeNo);
        return Result.ok(orderId.toString());
    }
}
